package com.teamwork.common.result;

import lombok.Data;

@Data
public class Result{

    private Integer code;
    private String message;
    private Object data;


    public  Result(){

    }

    //成功
    public static Result success(){
        Result result = new Result();
       result.setCode(ResultConstants.OK);
       result.setMessage("操作成功！");
        return result;
    }
    //成功，有数据
    public static Result success(Object data){
        Result result = new Result();
        result.setCode(ResultConstants.OK);
        result.setData(data);
        return result;
    }
    //成功，有信息
    public static Result success(String message){
        Result result = new Result();
        result.setCode(ResultConstants.OK);
        result.setMessage(message);
        return result;
    }
    //成功，有信息，数据
    public static Result success(String message,Object data){
        Result result = new Result();
        result.setCode(ResultConstants.OK);
        result.setMessage(message);
        result.setData(data);
        return result;
    }
    //成功，自定义状态码
    public static Result success(Integer code,String message,Object data){
        Result result = new Result();
        result.setCode(code);
        result.setMessage(message);
        result.setData(data);
        return result;
    }
    //失败，
    public static Result failure(){
        Result result = new Result();
        result.setCode(ResultConstants.ERR);
        result.setMessage("操作失败！");
        return result;
    }
    //失败，自定义信息
    public static Result failure(String message){
        Result result = new Result();
        result.setCode(ResultConstants.ERR);
        result.setMessage(message);
        return result;
    }
    //失败，有数据
    public static Result failure(String message,Object data){
        Result result = new Result();
        result.setCode(ResultConstants.ERR);
        result.setMessage(message);
        result.setData(data);
        return result;
    }
    public static Result failure(Integer code,Object data){
        Result result = new Result();
        result.setCode(ResultConstants.ERR);
       result.setCode(code);
        result.setData(data);
        return result;
    }
    //失败，自定义状态吗
    public static Result failure(Integer code,String message,Object data){
        Result result = new Result();
        result.setCode(ResultConstants.ERR);
        result.setCode(code);
        result.setMessage(message);
        result.setData(data);
        return result;
    }

}
